<template>
  <div class="page">
    <NavBar title='书架' :isBack='isBack' />
    <div class="main">
        <div class="list">
            <div class="item" v-for="(item,index) in list" :key="index">
                    <img :src="item.imgUrl" alt="" />
                <div class="text">
                    <div class="name">{{item.name}}</div>
                    <div class="right"><van-icon @click="del()" name="delete" size='17' /></div>
                </div>
            </div>
        </div>
    </div>
    <TabBar :currentIndex='currentIndex' />
  </div>
</template>
<script setup>
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";
import NavBar from "../components/NavBar.vue";
import TabBar from "../components/TabBar.vue";
import g1 from "../assets/img/g1.png";
import g2 from "../assets/img/g2.png";
import g3 from "../assets/img/g3.png";
import { showDialog ,showToast,showConfirmDialog} from "vant";
const router = useRouter();
const isBack = ref(false);
const currentIndex = ref(1);
let list =[
  {
    imgUrl:g1,
    name:'海底两万里'
  },
  {
    imgUrl:g2,
    name:'西南联大英文课'
  },
  {
    imgUrl:g3,
    name:'图书名称长度文学名家名著：孔乙己'
  },
]
const del =()=>{
      showConfirmDialog({
    title: "提示",
    confirmButtonColor: "#1e80ff",
    message: "确认删除吗？",
  })
    .then(() => {
      // on confirm
       showToast("删除成功");
    })
    .catch(() => {
      // on cancel
    });
}
onMounted(() => {
  console.log("mounted"); 
});
</script>
<style scoped lang="less">
.page {
  width: 100%;
  min-height: 100vh;
    background: #f8f8f8;
  // background-color: rgb(250, 244, 235);
}
.item{
    display: flex;
    margin: 15px;
    padding: 15px;
    background: #fff;
    border-radius: 10px;
    img{
        width: 120px;
        margin-right: 15px;
    }
    .text{
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 100%;
    }
    .right{
        width: 100%;
        margin-top: 30px;
        text-align: right;
    }
}
</style>
